]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
build: Define test dependencies
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 11 Sep 2025 11:29:31 +0000 (13:29 +0200)
committerMarge Bot <marge-bot@gnome.org>
Thu, 11 Sep 2025 16:18:25 +0000 (16:18 +0000)
Ideally meson tests should just work without any pre-requisite build,
instead, we only need a configured build folder to work, but this does
not go as expected in gnome shell at the moment.

Since tests require generated files and compiled typelibs they don't
depend on, so just using `meson test -C build <test-name>` does not work
as expected.

So add test dependencies on test cases. We do not need to have per-test
dependencies right now since most of them share just the same
requirements, and this makes it easier to maintain

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3869>

data/meson.build
src/meson.build
src/st/meson.build
tests/meson.build

index d48308743cbf29c64b767ba8d28694f6e2a4a128..cc7b5e2a1fe6dbc2245ea718d19a62f6a8db43f6 100644 (file)
@@ -59,11 +59,12 @@ data_resources = [
   {'name': 'osk-layouts'},
   {'name': 'theme', 'deps': theme_deps}
 ]
+data_resources_targets = []
 foreach resource : data_resources
   name = resource.get('name')
   deps = resource.get('deps', [])
 
-  gnome.compile_resources(
+  data_resources_targets += gnome.compile_resources(
     'gnome-shell-' + name,
     'gnome-shell-@0@.gresource.xml'.format(name),
     source_dir: name,
@@ -150,8 +151,8 @@ if have_systemd
 endif
 
 # for unit tests - gnome.compile_schemas() only looks in srcdir
-custom_target('compile-schemas',
+compiled_schemas = custom_target('compile-schemas',
   input: schema,
   output: 'gschemas.compiled',
   command: [find_program('glib-compile-schemas'), '--strict', data_builddir],
-  build_by_default: true)
+)
index b729ec03a933799162aa018158d9aeffd02f0b3c..a4ce889eac4f7fecd524e9dc6fa9ca7cb9e150a0 100644 (file)
@@ -282,7 +282,7 @@ libshell_gir = gnome.generate_gir(libshell,
   kwargs: introspection_common,
 )
 
-executable('gnome-shell', 'main.c',
+gnome_shell_binary = executable('gnome-shell', 'main.c',
   c_args: gnome_shell_cflags + typelib_cflags,
   dependencies: gnome_shell_deps + [libshell_dep, libst_dep, mutter_dep],
   include_directories: [conf_inc],
@@ -302,7 +302,7 @@ if have_portal_helper
   )
 endif
 
-executable('gnome-shell-perf-helper', 'shell-perf-helper.c', js_resources,
+gnome_shell_perf_helper = executable('gnome-shell-perf-helper', 'shell-perf-helper.c', js_resources,
   dependencies: [gtk_dep, gio_dep, m_dep],
   include_directories: [conf_inc],
   install_dir: libexecdir,
index 5fb742b259a270311a567f25fe29df213b57ffce..693a143f4f6b8c877766cc778262ec21b37d2f04 100644 (file)
@@ -225,6 +225,7 @@ if get_option('tests') and have_x11_client
 
   test('css-styling', test_theme,
     suite: 'st',
+    depends: compiled_schemas,
     workdir: meson.current_source_dir(),
   )
 endif
index 6882e44bce7b06316945477441b727c4322f626a..806a0c7adc9d5e60f7cecaa7d06b045fee3efbac 100644 (file)
@@ -13,6 +13,15 @@ gvc_typelib_path = fs.parent(libgvc.get_variable('libgvc_gir')[1].full_path())
 shell_typelib_path = fs.parent(libshell_gir[1].full_path())
 st_typelib_path = fs.parent(libst_gir[1].full_path())
 
+# Shared tests dependencies.
+tests_dependencies = [
+  compiled_schemas,
+  data_resources_targets,
+  libst_gir[1],
+  libshell_gir[1],
+  libgvc_gir[1],
+]
+
 unit_testenv = environment()
 unit_testenv.set('GNOME_SHELL_DATADIR', data_builddir)
 unit_testenv.append('GI_TYPELIB_PATH', gvc_typelib_path, separator: ':')
@@ -59,6 +68,7 @@ foreach test, extra_args : unit_tests
       'unit/@0@.js'.format(test),
     ],
     suite: 'unit',
+    depends: tests_dependencies,
     env: local_test_env,
     protocol: 'tap',
     workdir: meson.current_source_dir())
@@ -106,6 +116,11 @@ foreach shell_test : shell_tests
       options,
       '@0@/shell/@1@.js'.format(meson.current_source_dir(), test_name),
     ],
+    depends: [
+      gnome_shell_binary,
+      gnome_shell_perf_helper,
+      tests_dependencies,
+    ],
     is_parallel: false,
     env: shell_testenv,
   )